﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace student
{
    public partial class Form3 : Form
    {
        private int id;
        private int age;
        private string Name;
        private decimal score;

        public Form3(int id, string name, int age, decimal score)
        {
            InitializeComponent();
            this.id = id;
            this.Name = name;
            this.age = age;
            this.score = score;
        }


        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(txbid.Text);
                int age = Convert.ToInt32(txbage.Text);
                decimal score = Convert.ToDecimal(txbscore.Text);
                string sql = string.Format("update Students set Name='{0}',Age={1},Score={2} where Id={3}", txbname2.Text, age, score, id);
                bool jg = DBHelper.ExecuteNonQuery(sql);
                if (jg)
                {
                    MessageBox.Show("修改成功");
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("修改失败");
            }
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            txbid.Text = id.ToString();
            txbname2.Text = Name;
            txbage.Text = age.ToString();
            txbscore.Text = score.ToString();
        }
    }
}
